/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package extension.game.poker;

import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;
import log.Debug;

/**
 *
 * @author daz
 */


public class StandUpHandler extends BaseClientRequestHandler {

    @Override
    public void handleClientRequest(User user, ISFSObject params) {
        int pos = params.getInt("stand_up_pos");
        Debug.d(user.getName() + " stand up id :" + pos);
        PokerRoomExtension pokerRoomExtension = (PokerRoomExtension) getParentExtension();
        PokerGame pokerGame = pokerRoomExtension.getPokerGame();
        Response response = pokerRoomExtension.getResponse();
        pokerGame.removePlayer(user);
        response.sendStandUp(params, pokerGame.getPlayerLeaveBetMoney(), pokerGame.getPlayerLeaveMoney(), pokerRoomExtension.getParentRoom().getPlayersList());
        Debug.d("current turn :" + pokerGame.getBettingTurn());
        if (pos == pokerGame.getBettingTurn()) {
            pokerGame.nextTurn();
        }
        pokerRoomExtension.getResponse().sendMessageChat(user.getName() + " rời bàn", 0);
    }
    
}
